package com.twu.biblioteca;


import java.util.List;

public class BookReservationOption implements CustomerOptionHandler{
    private Library library;
    public BookReservationOption(Library library) {
        this.library = library;
    }

    public String customerOption() {
        User user = library.getUser();
        if(user.hasLoggedIn()){
            List<Book> books = library.getBooks();
            String bookName = library.bookReservationRequest();

            for (Book book : books) {
                if (book.getBookName().equals(bookName) && book.isAvailable()) {
                    book.checkout();
                    return "Thank You! Enjoy the book.";
                }
            }
            return "Sorry we don't have that book yet.";

        }else {
            return "You have not logged in yet";
        }


    }

}
